package main_com.mapper;

import main_com.pojo.FileBean;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;

@Mapper
public interface FileMapper {
    @Insert("insert into file values(#{userName},#{title},#{name},#{contentType},#{size},#{filePath})")
    void addFile(FileBean file);

    @Select("select * from file where userName=#{userName}")
    ArrayList<FileBean> getFileByUserName(String userName);

    @Select("select count(*) from file where userName=#{userName} and name=#{fileName}")
    int findFileCountByUserNameAndFileName(String userName, String fileName);

    @Delete("delete from file where userName=#{userName} and name=#{fileName}")
    void deleteFiles(String userName, String fileName);
}
